package com.geeguo.ebuilder.core.common.model.vo;

import com.geeguo.ebuilder.core.common.model.query.Pagination;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Collections;
import java.util.List;

/**
 * @author LiangHe
 */
@Data
@NoArgsConstructor
public class PageListVO<T> {

    private List<T> list;
    PaginationVO pagination;

    public PageListVO(PaginationVO pagination, List<T> list) {
        this.pagination = pagination;
        this.list = list;
    }

    public static <T> PageListVO<T> empty(Pagination query) {
        PaginationVO pagination = new PaginationVO();
        pagination.setPageNo((long) query.getPageNo());
        pagination.setPageSize((long) query.getPageSize());
        pagination.setTotal(0L);
        return new PageListVO<>(pagination, Collections.emptyList());
    }
}